
-- =============================================  
-- Author:  Raul Esquer  
-- Create date: 11/06/2012  
-- Description: Guardar las tecnologias de un recurso 
-- [Resource_C_Detail]  1, '<Root><TecnologyInfo><Id>1</Id><Description>Java</Description></TecnologyInfo><TecnologyInfo><Id>6</Id><Description>JavaScript</Description></TecnologyInfo></Root>'
-- =============================================  
CREATE PROCEDURE [dbo].[Resource_C_Detail] 

@Id INT, 
@TecnologyList NVARCHAR(MAX)

AS  
BEGIN  
 SET NOCOUNT ON;       
	DECLARE @idoc int
	EXEC sp_xml_preparedocument @idoc OUTPUT, @TecnologyList 
	
	DELETE TecnologiaRecurso WHERE recursoId = @Id	
	
	INSERT INTO TecnologiaRecurso (recursoId, tecnologiaId) 	
	SELECT @Id, Id
	FROM   OPENXML (@idoc, '/Root/TecnologyInfo',2)
    WITH (Id int)
               
    EXEC sp_xml_removedocument @idoc		
 SET NOCOUNT OFF  
END

